import { ActionContext } from 'vuex'
import { IRootState } from '../../rootState'
import { state, getters, AppState } from './entity'

const mutations = {
    SET_APP_INFO(state: AppState): void {
        state.statusBarHeight = state.appInfo.statusBarHeight;
        state.platform = state.appInfo.platform;
    },
    // 设置版本号
    SET_VERSION: (state: AppState, version: string) => {
        uni.setStorageSync('version', version);
        state.version = version;
    },
}

const actions = {
    SetVersion({ commit }: ActionContext<AppState, IRootState>, version: string) {
        commit('SET_VERSION', version);
    }
}

export default {
    namespace: 'app',
    state,
    mutations,
    actions,
    getters
};